<template>
<h1>EL-表格组件</h1>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="date" label="日期" width="180" />
    <el-table-column prop="name" label="姓名" width="180" />
    <el-table-column prop="address" label="住址" />
  </el-table>
  <hr>
  <el-table :data="arr" style="width: 100%;">
    <el-table-column prop="num" label="编号" type="index" width="180" />
    <el-table-column prop="name" label="姓名" width="180" />
    <el-table-column prop="salary" label="工资" width="180" />
    <el-table-column prop="job" label="职位" />
    <el-table-column>
      <template #default="scope">
        <el-button type="danger" @click="del(scope.$index,scope.row)">删除</el-button>
      </template>

    </el-table-column>



  </el-table>
</template>

<script setup>
import {ref} from "vue";

const del = (i,emp)=>{
  //console.log(i);
  //console.log(emp);
  if (confirm('您确认要删除'+emp.name+'吗?')){
    arr.value.splice(i, 1);
  }
  alert('删除成功');
}
const tableData = [
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
]

const arr = ref(
    [
      {name:'张三',salary:234,job:'门卫'},
      {name:'李四',salary:23423,job:'外卖员'},
      {name:'王五',salary:574,job:'监控大爷'},
      {name:'赵六',salary:867,job:'保安队长'},
    ]
)
</script>

<style scoped>

</style>